*Order the data 
xtset pcode year

*Figure 1
graph twoway (scatter avgdom political_inexperience if leadertermattempt==0, msymbol(oh) jitter(5) mcolor(navy%20)) ///
(scatter avgdom political_inexperience if leadertermattempt==1, msymbol(T) jitter(5) mcolor(red%90))

*Table 2. Presidential Attempts to Relax Term Limits

* Model 2.1 conventional arguments  
drop if avgdom==.
drop if political_inexperience==.
xtprobit leadertermattempt g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2  v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model21

* Model 2.2 Presidential Attempts (benchmark model)  
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model22

* Model 2.3 Successful Attempts 
xtprobit successtermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model23

* Model 2.4 Years in Politics
xtprobit leadertermattempt avgdom revyears_inpolitics g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model24

* Model 2.5 Total Inexperience 
xtprobit leadertermattempt avgdom political_inexperience_dummy g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model25

* Model 2.6 Endogeneity
eprobit leadertermattempt political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3, endogenous (avgdom= birth_order first_child entrepreneur foreigner political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3)
eststo model26

* Model 2.7 Two-Stage Model 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp imr yearsinoffice yearsinoffice2 yearsinoffice3
eststo model27

** Model 2.8 Cross-Sectional	  
collapse leadertermattempt successtermattempt avgdom political_inexperience g_hapl enphapl agepartylog ageparty stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 political_inexperience_dummy, by(pcode2) 

**Adjust DV to be dichotomous as in all previous models.   
replace leadertermattempt=1 if leadertermattempt >0
replace successtermattempt=1 if successtermattempt >0

**These leaders must be dropped from the sample because they already tried to relax their term limits in a previous non-consecutive term. 
drop if pcode2== 4219861
drop if pcode2== 9119721
drop if pcode2== 14019511
drop if pcode2== 14519851
drop if pcode2== 9319502


**LABELS: 
label variable agepartylog "Party Age (log)"
label variable ageparty "Party Age"
label variable gpgdp "GDP per Capita"
label variable stronglegpower "Leg. Powers"
label variable strongnon_legpower "Non-Leg. Powers"
label variable amnvariable "Amendment"
label variable g_hapl "Congress"
label variable yearsinoffice "Time in Office" 
label variable yearsinoffice2 "Time in Office2"
label variable yearsinoffice3 "Time in Office3"
label variable avgdom "Dominance"
label variable political_inexperience "Inexperience" 
label variable enphapl "Number of Parties"
label variable noreelection "No Reelection"
label variable amnvariable "Amendment"
label variable polityivpolity2 "Regime"
label variable v2juhcind "Higher Courts"
label variable political_inexperience_dummy "Inexperience"

probit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp

eststo model28

* Table 2, integrated  
esttab model21 model22 model23 model24 model25 model26 model27 model28 using "Table2.rtf", cell(b(star fmt (%9.2f)) se(par))stats(N r2, fmt(%9.0g %9.3f) labels("N"))starlevels(* 0.1 ** 0.05 *** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 2. Presidential Attempts to Relax term Limits") mtitles replace

*Start again with data
clear
use "Presidents&TermLimits.dta"

*Order the data 
xtset pcode year
	   
* Figure 2 
probit leadertermattempt g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3, nolog
predict inst 

probit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3, nolog
predict indiv 

roccomp leadertermattempt inst indiv, graph summary

* Figure 3
*model 2.2 benchmark  
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3

*Left side
margins, predict (pu0) at( avgdom =(2 (.5) 5) )
marginsplot, addplot(hist avgdom if e(sample), yaxis(2) legend(off) color(gs%15) ylabel(,noticks nolabel axis(2)) ytitle("", axis(2)))

*Right side

margins, predict (pu0) at( political_inexperience =(1 (1) 4) )
marginsplot, addplot(hist political_inexperience if e(sample), yaxis(2) legend(off) color(gs%15) ylabel(,noticks nolabel axis(2)) ytitle("", axis(2)))

* Table 3. Robustness Checks on Presidential Attempts to Relax term Limits

* Model 3.1 No Extreme Raters
xtprobit leadertermattempt avgdomperf political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model31

* Model 3.2 Interaction Dominance 
xtprobit leadertermattempt c.avgdom##c.polityivpolity2 political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3

eststo model32

* Model 3.3 Interaction Inexperience
xtprobit leadertermattempt avgdom c.political_inexperience##c.polityivpolity2 g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model33

* Model 3.4 interaction Hypotheses
xtprobit leadertermattempt c.avgdom##c.political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model34

* Model 3.5 Majority Party 
xtprobit leadertermattempt avgdom political_inexperience mp_h g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model35 

* Model 3.6 Age 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 agepres 
eststo model36

* Model 3.7 Education 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 education
eststo model37

* Model 3.8 Ideology 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 political_ideology1
eststo model38

* Table 3, integrated  
esttab model31 model32 model33 model34 model35 model36 model37 model38 using "Table3.rtf", cell(b(star fmt (%9.2f)) se(par))stats(N r2, fmt(%9.0g %9.3f) labels("N"))starlevels(* 0.1 ** 0.05 *** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 3. Robustness Checks on Presidential Attempts to Relax term Limits") mtitles replace


************************The following goes in the online appendix  

* Figure 4 Interaction of Independent Variables and Regime (in Online Appendix) 

* Left-side (dominance)
xtprobit leadertermattempt c.avgdom##c.polityivpolity2 political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
margins, dydx(avgdom) at(polityivpolity2=(-10 (1) 10))
marginsplot, level(95)

* Right-side (inexperience)
xtprobit leadertermattempt avgdom c.political_inexperience##c.polityivpolity2 g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
margins, dydx(political_inexperience) at(polityivpolity2=(-10 (0.5) 10))
marginsplot, level(95)

* Table 7. Additional Robustness Checks on Presidential Attempts
* Model 7.1 Extraversion

xtprobit leadertermattempt avgextraversion political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model71

* Model 7.2 Combined Inexperience
xtprobit leadertermattempt avgdom indexpolexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model72

* Model 7.5 Populist 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 populist 
eststo model75

* Model 7.6 Expected Years Left   
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 expected_years_left
eststo model76

* Model 7.7 Inexperience*Party Age   
xtprobit leadertermattempt avgdom c.political_inexperience##c.agepartylog g_hapl enphapl stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model77

* Model 7.8 Opposition Parties 
xtprobit leadertermattempt avgdom political_inexperience g_hapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp  yearsinoffice yearsinoffice2 yearsinoffice3 enpoapl
eststo model78

* Model 7.9 Legislative Constraints 
xtprobit leadertermattempt avgdom political_inexperience enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 v2xlg_legcon 
eststo model79
 
* Model 7.10 Judicial Constraints 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 v2x_jucon
eststo model710

* Model 7.11 Raw Materials 
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3 oilmin 
eststo model711

* Model 7.3 Neither Puppets nor Interims 
drop if interim==1
drop if puppet==1
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model73

*Start again with data
clear
use "Presidents&TermLimits.dta"

*Order the data 
xtset pcode year

* Model 7.4 Early Exit 
drop if early_exit_termdel==1
xtprobit leadertermattempt avgdom political_inexperience g_hapl enphapl agepartylog stronglegpower strongnon_legpower noreelection amnvariable polityivpolity2 v2juhcind gpgdp yearsinoffice yearsinoffice2 yearsinoffice3
eststo model74


esttab model71 model72 model73 model74 model75 model76 model77 model78 model79 model710 model711 using "Table7.rtf", cell(b(star fmt (%9.2f)) se(par))stats(N r2, fmt(%9.0g %9.3f) labels("N"))starlevels(* 0.1 ** 0.05 *** 0.01) legend label varlabels(_cons Constant)title("Table 4. Presidential Attempts to Increase Powers") mtitles replace
	  

* Table 6. Probability that a President will be Assessed.  
**Note: this table uses data from all participants in expert survey, so it needs to use Table6Data
clear   
use Table6Data.dta
generate countrysizeA = countrysize/100000
generate gdpA = gdp /10000
generate populationA = population/1000
generate totaltime_in_officeA = totaltime_in_office/365
generate cites2A = cites2/1000

label variable countrysizeA "Country Size"
label variable gdpA "GDP"
label variable totaltime_in_officeA "Total Time in Office"
label variable cites2A "Google Mentions"

collapse rated countrysizeA gdpA populationA totaltime_in_officeA cites2A, by(pcode) 

probit rated countrysizeA gdpA totaltime_in_officeA cites2A

pre 

* Post-estimation
estat class

* Marginal Effects After Probit
mfx
